package com.imaker.service;

import java.util.List;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.imaker.dao.BaseDao;
import com.imaker.domain.FastOperatInfo;
import com.imaker.field.StaticField;

 /**
 * <p>程序名称：       FastOperatService.java</p>
 * <p>程序说明：       top栏基本信息Service</p>
 * <p>版权信息：       Copyright mayonghua</p>
 * <p>时间：          Oct 22, 2010 4:44:57 PM</p>	
 * 
 * @author：          mayonghua
 * @version：         Ver 0.1
 */
@Service
public class FastOperatService implements IService {
	private BaseDao<FastOperatInfo> baseDao = null;
	@Autowired
	public void setSessionFactory(SessionFactory sessionFactory) {
		baseDao = new BaseDao<FastOperatInfo>(sessionFactory,FastOperatInfo.class);
	}
	/**
	 * 查找所有列表
	 */
	public List<FastOperatInfo> findAll(){
		
		List<FastOperatInfo> list = null;
		try {
			list = baseDao.find("from FastOperatInfo f");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return list;
	}
	/**
	 * 添加
	 * @throws Exception 
	 */
	public String save(FastOperatInfo fastOperatInfo){
		try {
			baseDao.save(fastOperatInfo);
		} catch (Exception e) {
			e.printStackTrace();
			return StaticField.error;
		}
		return StaticField.success;
	}
	/**
	 * 删除
	 */
	public String delete(List idList){
		try {
			baseDao.deleteByIdList(idList);
		} catch (Exception e) {
			e.printStackTrace();
			return StaticField.error;
		}
		return StaticField.success;
	}
	/**
	 * 更新
	 */
	public String update(FastOperatInfo fastOperatInfo){
		try {
			baseDao.update(fastOperatInfo);
		} catch (Exception e) {
			e.printStackTrace();
			return StaticField.error;
		}
		return StaticField.success;
	}
	
	/**
	 * 根据ID查询
	 * @param FastOperatInfo
	 * @return
	 * @throws Exception
	 */
	public FastOperatInfo findById(FastOperatInfo fastOperatInfo) throws Exception{ 
		return baseDao.get(fastOperatInfo.getId());
	}
}
